package com.yuyu.excel.controller;

import com.yuyu.excel.service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.concurrent.Executor;

@RestController
@RequestMapping("/excel")
public class ExcelController {

    @Resource
    private UserService userService;

    @GetMapping("/getModel")
    public void getExcelModel(HttpServletResponse resp) {
        userService.downloadExcelModel(resp);
    }

    @PostMapping("/import")
    public String importExcel(@RequestParam MultipartFile file) {
        userService.importExcel(file);
        return "导入成功";
    }

    @PostMapping("/export")
    public void exportExcel(HttpServletResponse resp) {
        userService.exportExcel(resp);
    }

}
